var api = require('../../utils/api.js');
var WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
   list:[]
  },

  onLoad(){
    this.loadswiper();
    this.loadcompanyinfo();
    this.loaddata();
  },
  //加载品牌列表
  loaddata() {
    api.get({
      url: 'home/brands/lists',
      data: {
        field: 'name,image',
        order: '+list_order'
      },
      success: data => {
        console.log(data.data)
        if (data.code == '1') {
          this.setData({
            list: data.data
          })
        }
      }
    })
  },
 
  loadswiper() {
    api.get({
      url: 'home/slides/7',
      success: data => {
        if (data.code == 1) {
          this.setData({
            movies: data.data[0].items
          })
        }
      }
    });
  },
  //获取公司介绍
  loadcompanyinfo() {
    api.get({
      url: 'portal/pages/131',//131吉诚公司介绍
      success: data => {
        if (data.code == '1') {
          WxParse.wxParse('articleContent', 'html', data.data.post_content, this, 30);
        }
      }
    })
  },
  formSubmit(e) {
    //提交表单数据
    api.post({
      url: '/portal/diyform/insert',
      data: e.detail.value,
      success: data => {
        if (data.code == "1") {
          wx.showToast({ title: '报名成功', icon: 'success' })
        }
        if (data.code == "0") {
          wx.showToast({ title: data.msg, icon: 'none' })
        }
      }
    })
  },

})